package com.zhuangjie.coupon.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zhuangjie.base.constant.CommonSeparatorConstants;
import com.zhuangjie.coupon.enums.*;
import com.zhuangjie.mvc.validator.annotate.ValidNumberEnumsString;
import com.zhuangjie.mvc.validator.annotate.enum_valid.EnumValid;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 *  店铺设置优惠卷批次dto
 * </p>
 *
 * @author zhuangjie
 * @since 2024-03-04
 */
@Data
public class ShopCouponBatchDTO implements Serializable {


    @ApiModelProperty("批次编号")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("优惠卷名称")
    @TableField("name")
    @NotBlank(message = "优惠券名称不能为空")
    private String name;

    @ApiModelProperty("批次状态（0不可领取 1可领取）")
    @TableField("status")
    private Byte status;

//    @ApiModelProperty("描述信息（如规则描述）")
//    @TableField("describe")
//    private String describe;

    @ApiModelProperty("总数量")
    @TableField("total")
    @Min(value = 1,message = "优惠券张数至少一张")
    @NotNull(message = "优惠券张数不能为空")
    private Integer total;

    @ApiModelProperty("优惠卷类型(0满减/无门槛卷/代金券，1折扣卷)")
    @TableField("type")
    @EnumValid(CouponType.class)
    private Byte type;

    @ApiModelProperty("最低消费多少金额可用优惠券（门槛）")
    @TableField("threshold_amount")
    private BigDecimal thresholdAmount;

    @ApiModelProperty("优惠卷值(根据type：抵扣金额 | 折扣率)")
    @TableField("par_value")
    @NotNull(message = "优惠券面额不能为空")
    private BigDecimal parValue;

    @ApiModelProperty("获取方式（  -1:兑换码 , 1:店铺公开展示-手动领取. 2:非公开群内手动领取  ）")
    @TableField("obtain_way")
    @EnumValid(CouponAcquisitionMethodType.class)
    private Byte obtainWay;

    @ApiModelProperty("每人限领张数")
    @TableField("per_person_limit")
    @NotNull(message = "每人限领张数不能为空")
    @Min(value = 1,message = "每人最少限领一张")
    private Integer perPersonLimit;

    @ApiModelProperty("使用有效期类型（1:固定日期 2:相对有效期）")
    @TableField("usage_validity_period_type")
    @EnumValid(CouponUsageValidityPeriodType.class)
    private Byte usageValidityPeriodType;

    @ApiModelProperty("自领取之日起有效天数（单位：天）")
    @TableField("usage_period_days")
    @Min(value = 1,message = "领取后有效期最少一天")
    private Integer usagePeriodDays;

    @ApiModelProperty("开始使用时间")
    @TableField("usage_start_time")
    private LocalDateTime usageStartTime;

    @ApiModelProperty("结束使用时间")
    @TableField("usage_end_time")
    private LocalDateTime usageEndTime;

    @ApiModelProperty("适用类型（0:无适用限制 1:适用类别 2:适用商品）")
    @TableField("applicable_type")
    @EnumValid(CouponApplicationType.class)
    private Byte applicableType;

    @ApiModelProperty("适用逻辑（1:适用选择 2:不适用选择的）")
    @TableField("applicable_logic")
    @EnumValid(value = CouponApplicationLogicType.class,allowNull = true)
    private Byte applicableLogic;

    @ApiModelProperty("适用值（选择的类目ids或商品ids）")
    @TableField("applicable_values")
    @ValidNumberEnumsString(delimiter = CommonSeparatorConstants.MULTIPLE_SEPARATOR)
    private String applicableValues;

    @ApiModelProperty("是否可以叠加使用(0 不可叠加 1可叠加)")
    @TableField("is_stackable")
    @NotNull(message = "是否可以叠加使用不能为空")
    private Boolean isStackable;


}
